<html>

<head>

    <title>{$site_name}-会员充值</title>

    <style type="text/css">
        #two-con{
            width: 700px;
        }

        input{
            height:34px !important;
            line-height:32px !important;
        }
        #two-con .control-label {
            float: left;
            width: 90px;
            padding-top: 5px;
            text-align: right;
        }
        #two-con input.span4{
            width: 200px;
        }
        #two-con select{
            height: 34px;
            line-height: 34px;
        }
        #two-con select.span4{
            width: 214px;
        }
        /*tips*/
        #two-con .help-inline {
            display: block;
            margin-bottom: -20px;
            *zoom: 1;
            font-size: 14px;
        }
        #two-con .controls {
            *display: inline-block;
            *padding-left: 20px;
            margin-left: 110px;
            *margin-left: 0
        }
        .reposition{
            width: 350px;
            float: left;
        }
        #btn-order-print{
            padding-left: 10px;
            display: inline-block;
            height: 20px;
            text-decoration: none;
        }
        input[type="checkbox"] {
            margin: 0px !important;
        }
    </style>

    <tc_include file="Public:head" />

</head>

<body class="body-white" id="top">

<tc_include file="Public:nav" />

<div class="container tc-main">

    <div class="row">

        <div class="span2">

            <tc_include file="Public:usernav"/>

        </div>

        <div class="span10">
            <h3 style="margin-left:280px;color: #ff0000;">{$menu_name}</h3>

            <form class="form-horizontal" id="dd" action="{:leuu('User/Info/docashadd')}">
                <input type="hidden" value="{$userinfo.cardnum}" name="cardnum">
                <input type="hidden" value="{$userinfo['usedstore']/100}" name="usedstore">
                <input type="hidden" value="{$userinfo.name}" name="name">
                <input type="hidden" value="{$userinfo.costcount}" name="costcount">
                <div class="control-group">
                    <label class="control-label" for="storedmoney"><span style="color: red;">*</span>充值金额:</label>
                    <div class="controls">
                        <input type="number" id = "storedmoney"  onkeyup="changeStore(this.value)" name="storedmoney" class="span4">
                        <span class="help-inline" id = 'storedmoneystr' style="color: red;"></span>
                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label" for="storedsendmoney">赠送金额:</label>
                    <div class="controls">
                        <input type="number" id="storedsendmoney" onkeyup="changeStoreSend(this.value)" name="storedsendmoney" class="span4">
                        <span class="help-inline" id="storedsendmoneystr" style="color: red;"></span>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="remark">备注:</label>
                    <div class="controls">
                        <textarea  id="remark" name="remark" style="width: 355px;height: 100px;"></textarea>
                        <span class="help-inline"></span>
                    </div>
                </div>

                <div class="control-group" style="margin-top: 20px;">
                    <label class="control-label" for=""></label>
                    <!--<p style="margin-bottom: 10px">-->
                        <!--<input type="checkbox" id="print-check">-->
                        <!--<a href="javascript:void(0)" id="btn-order-print" >打印</a>-->
                    <!--</p>-->
                    <div class="controls">
                        <button class="btn btn-primary js-ajax-submit span4" type="button" style="margin-left: 0px" id="subbtn">确定</button>
                    </div>
                </div>
            </form>

            <hr>

            <div id="two-con" style="margin-left: 70px">
                <div>
                    <div class="control-group reposition">
                        <label class="control-label" for="cardnum"><span style="color: red;">*</span>会员卡号:</label>
                        <div class="controls">
                            <input type="text" value="{$userinfo.cardnum}" disabled name="cardnum" class="span4" id="vipcardnum">
                        </div>
                    </div>
                    <div class="control-group reposition">
                        <label class="control-label" for="uname">姓名:</label>
                        <div class="controls">
                            <input type="text" id="name" name="uname" disabled value="{$userinfo.name}" class="span4" >
                            <div style="clear: both;"></div>
                        </div>
                    </div>
                    <div class="control-group reposition">
                        <label class="control-label" for="cardlevel"><span style="color: red;">*</span>会员级别:</label>
                        <div class="controls">
                            <input type="text" value="{$userinfo.cardname}" disabled name="cardname" class="span4">
                        </div>
                    </div>
                    <div class="control-group reposition">
                        <label class="control-label" for="usedstore">可用储值:</label>
                        <div class="controls">
                            <input type="text" id="usedstore" disabled name="usedstore" value="{$userinfo['usedstore']/100}" class="span4">
                        </div>
                    </div>
                    <div class="control-group reposition">
                        <label class="control-label" for="cardtype">会员卡类型:</label>
                        <div class="controls">
                            <if condition="$userinfo['cardtype']=='times'">
                                <input type="text" disabled value="天数卡" name="cardtype" class="span4">
                                <else/>
                                <input type="text" disabled value="现金充值卡" name="cardtype" class="span4">
                            </if>
                        </div>
                    </div>
                    <div class="control-group reposition">
                        <label class="control-label" for="usedtime">有效期:</label>
                        <div class="controls">
                            <input type="text" id="usedtime"  disabled value="{$userinfo.usedtime}" name="usedtime" class="span4">
                        </div>
                    </div>
                    <div style="clear: both"></div>
                </div>

            </div>
    <div  style="margin-bottom: 430px"></div>
    <div id="print-container" style="width: 200px;padding: 0px 10px;">
        <div class="print-page-block clearfix">
            <div>
                <p>充值时间：<span id="recharge-time" style="font-size: 13px"></span></p>
                <p>联系电话：0377-61652288</p>
            </div>
        </div>
        <hr style="border-top: 1px dashed !important;">
        <div>
            <p>业务类型：会员充值</p>
            <p>充值金额：<strong><span class="recharge-num"></span></strong></p>
            <p>到账金额：<strong><span id="total-num"></span></strong></p>
        </div>
        <hr style="border-top: 1px dashed !important;">
        <div>
            <p>现金支付：<strong><span class="recharge-num"></span></strong></p>
        </div>
        <hr style="border-top: 1px dashed !important;">
        <div>
            <p>会员卡号：<span id="vip-card-num"></span></p>
            <p>会员姓名：<span id="vip-name"></span></p>
            <p>储值余额：<strong><span id="vip-total"></span></strong></p>
            <p>备注：<strong><span id="remark-txt"></span></strong></p>
        </div>
        <div>
            <hr style="border-top: 1px dashed !important;">
            本小票由天佑康宁提供
        </div>
    </div>
</div>

<!-- /container -->

<tc_include file="Public:scripts" />

<script src="__PUBLIC__/js/tools.js"></script>
<script src="__PUBLIC__/js/jquery.print.js"></script>
<script type="text/javascript">
    $(function () {
        $('#print-container').hide();
        console.log(2);
//            充值时间
        var myDate = new Date();
        var myYear = myDate.toLocaleDateString();
        var mytime=myDate.toLocaleTimeString();
        var timeStr = myYear + mytime;
        $('#recharge-time').html(timeStr);
//            充值金额
        $(document).keyup(function () {
            var rechargeNum = $('#storedmoney').val();
            var sendMoney = $('#storedsendmoney').val();
            var totalNum = Number(rechargeNum) + Number(sendMoney);
            var nowNum = $('#usedstore').val();
            var remark = $('#remark').val();
            var vipTotalNum = Number(nowNum) + totalNum;
            $('.recharge-num').html(rechargeNum);
            $('#total-num').html(totalNum);
            $('#vip-total').html(vipTotalNum);
            $('#remark-txt').html(remark);

        })
//            会员信息
        var vipCardNum = $('#vipcardnum').val();
        var vipName = $('#name').val();
        var nowNum = $('#usedstore').val();
        var remark = $('#remark').val();
        $('#vip-card-num').html(vipCardNum);
        $('#vip-name').html(vipName);
        $('#vip-total').html(nowNum);
        $('#remark-txt').html(remark);
    })

    $('#subbtn').click(function() {
        if($('#print-check').attr('checked')){
//            var order_id = $(this).data('id');
            var print_container = $('#print-container');
            $('#print-container').show();
            print_container.print({
                globalStyles: false,
                mediaPrint: false,
                stylesheet: '__PUBLIC__/simpleboot/css/print.css',
                noPrintSelector: ".no-print",
                iframe: true,
                append: null,
                prepend: null,
                manuallyCopyFormValues: true,
                deferred: $.Deferred(),
                timeout: 750,
                title: '订单打印',
                doctype: '<!doctype html>'

            });

        }
        $.post("{:leuu('User/Store/docashadd')}",$('#dd').serialize(),function(data){

            document.getElementById('subbtn').disabled=true;

            if(data.status == 1) {

                if(data.url) {

                    window.location.href=data.url;

                } else {

                    location.reload();

                }

            } else {

                alert(data.info);
                document.getElementById('subbtn').disabled=false;

            }

        })

    });

    function changeStore(num) {
        var strOutput =  GetNumberForChinese(num);
        $('#storedmoneystr').html(strOutput);
    }

    function changeStoreSend(num) {
        var strOutput =  GetNumberForChinese(num);
        $('#storedsendmoneystr').html(strOutput);
    }

</script>

</body>

</html>
